<?php
/** @var Dingo\Api\Routing\Router $api */
$api->group([
    'version' => 'v1',
    'namespace' => 'App\Http\Controllers\Sdk',
    'prefix' => 'api/sdk',
    'middleware' => \App\Http\Middleware\SDKToken::class,
], function ($api) {
    // 代理的 ID 在 header 获取,
    $api->group(['prefix' => 'agents'], function () use ($api) {
        $api->get('/{id}', 'AgentController@info');
        $api->get('/by-phone/{phone}', 'AgentController@infoByPhone');
    });
    $api->group(['middleware' => \App\Http\Middleware\SDKAuth::class], function () use ($api) {
        $api->group(['prefix' => 'agents'], function () use ($api) {
            $api->post('/wallet/transfers', 'WalletController@transfersBalance'); // sdk 余额操作
            $api->get('/wallet/transfers', 'WalletController@transfersInfo'); // sdk 余额操作详情
        });
        // 代理商 客户
        $api->group(['prefix' => 'clients'], function () use ($api) {
            $api->post('/', 'ClientController@store'); // 创建同时也是详情,幂等用于保证一定能返回客户 ID
        });
        // 订单
        $api->group(['prefix' => 'orders'], function () use ($api) {
            $api->post('/', 'OrderController@store'); // (代理) 用户下单
            $api->get('/', 'OrderController@info'); // (代理) 用户订单详情
        });
        // 活动
        $api->group(['prefix' => 'commodities/activities'], function () use ($api) {
            $api->get('/', 'CommodityController@list'); // 列表
            $api->get('/{id}', 'CommodityController@info'); // 详情
        });
    });
});
